gdkoffscreenwindow: use embedder to derive surfaces & scale factor
authorLionel Landwerlin <llandwerlin@gmail.com>
Wed, 2 Dec 2015 01:41:07 +0000 (01:41 +0000)
committerLionel Landwerlin <llandwerlin@gmail.com>
Thu, 3 Dec 2015 21:47:29 +0000 (21:47 +0000)
In Gdk, a GdkOffscreenWindow parent has to be the root window. This is
problematic on Wayland because the root window doesn't necessary have the
right information with regard to scale factor.

This patch proposes to rely on the embedder, if available, to derive
surfaces as well as getting the scale factor.

https://bugzilla.gnome.org/show_bug.cgi?id=758936

gdk/gdkoffscreenwindow.c

index a022795db4b32923c63d2cecc64908df01cc089f..2caf0affe04dbcb02439e74c2f91164521197e27 100644 (file)
@@ -143,10 +143,16 @@ _gdk_offscreen_window_create_surface (GdkWindow *offscreen,
                                       gint       width,
                                       gint       height)
 {
+  GdkOffscreenWindow *impl;
+  GdkWindow *derived;
+
   g_return_val_if_fail (GDK_IS_OFFSCREEN_WINDOW (offscreen->impl), NULL);
 
-  return gdk_window_create_similar_surface (offscreen->parent,
-                                           CAIRO_CONTENT_COLOR_ALPHA, 
+  impl = GDK_OFFSCREEN_WINDOW (offscreen->impl);
+  derived = impl->embedder ? impl->embedder : offscreen->parent;
+
+  return gdk_window_create_similar_surface (derived,
+                                           CAIRO_CONTENT_COLOR_ALPHA,
                                            width, height);
 }
 
@@ -657,10 +663,15 @@ gdk_offscreen_window_get_frame_extents (GdkWindow    *window,
 static gint
 gdk_offscreen_window_get_scale_factor (GdkWindow *window)
 {
+  GdkOffscreenWindow *offscreen;
 
   if (GDK_WINDOW_DESTROYED (window))
     return 1;
 
+  offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
+  if (offscreen->embedder)
+    return gdk_window_get_scale_factor (offscreen->embedder);
+
   return gdk_window_get_scale_factor (window->parent);
 }